package com.example.demoamqp.receiver;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息接收者
 * 消息消费者
 *
 * @author Administrator
 */
@Component
public class Receiver {

    /**
     * 接收消息的方法。采用消息队列监听机制
     *
     * @param msg
     */
    @RabbitListener(queues = "ross_amq")
    public void process(String msg, Channel channel, Message message) {
        System.out.println("消息消费者：" + msg);
        System.out.println("消费者1channel通道编号为：" + channel.getChannelNumber());
        System.out.println("消费者1收到消息：" + new String(message.getBody()));
    }
}